utils.on(tbody,'click',e=>{
    const target= e.target;
    const tr = target.parentNode.parentNode;
    const spans = tr.querySelectorAll('span');
    const inputs = tr.querySelectorAll('input');
    // 编辑列表
    if(Array.from(target.classList).includes('btn-edit')){
        tr.classList.add('edit');
        for(var i=0; i<spans.length; i++){
            spans[i].nextSibling.value = spans[i].innerHTML;
        }
        for(var i=0; i<inputs.length;i++){
            inputs[i].onfocus = function(){
                this.value = null ;
            }
        }
    }

    //确定按钮
    if(Array.from(target.classList).includes('btn-ok')){
        tr.classList.remove('edit');
        const id = tr.getAttribute('data-id')
        for (var i=0; i<spans.length; i++){
            spans[i].innerHTML = spans[i].nextSibling.value;
            var name = spans[0].innerHTML;
            var price = spans[1].innerHTML;
            var num = spans[2].innerHTML;
        }
        utils.fetch('./api/shop/update.php',{id,name,price,num}).then(resp=>{
            if(resp.code === 1){
                alert(resp.body.msg)
            }else{
                aler(resp.body.msg)
            }
        })
    }
    //取消按钮
        if (Array.from(target.classList).includes('btn-cancel')) {
        tr.classList.remove('edit')
}
})














